// 给请求路径加上前缀
$.ajaxPrefilter(function(option) {
    option.url = `http://api-breakingnews-web.itheima.net${option.url}`
    if (option.url.includes('/my/')) {
        option.headers = {
            Authorization: localStorage.getItem('token')
        }
    }
    // 不论成功还是失败，都会调用complete函数
    option.complete = function(res) {
        // console.log(res);
        if (res.responseJSON.status === 1 && res.responseJSON.message === '身份认证失败！') {
            localStorage.removeItem('token')
            location.href = '/login.html'
        }

    }
})